import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { RootState } from ".";

export const pageSlice = createSlice({
  name: 'pageNumber',
  initialState: {
    value: {
      current: 1,
      size: 10,
    },
  },
  reducers: {
    setPageNumber: (state, action: PayloadAction<number>) => {
      state.value.current = action.payload
    },
    setPageSize: (state, action: PayloadAction<number>) => {
      state.value.size = action.payload
    },

  }
})

export const { setPageNumber, setPageSize } = pageSlice.actions
export default pageSlice.reducer

export const page = (state: RootState) => state.page.value
